/*************************************************
* Copyright(c) free                              *
* Beijing Jiaotong University                    *
* AUTHOR: Li Yi,Li Xuewen		         *				
* TEAM: Wasabi                                   *
* This file is the head of the TrieTree.c        *
* Version 1.0 2011-01-06                         *
*************************************************/


#ifndef __TRIETREE_H__
#define __TRIETREE_H__
typedef struct _TrieNode{
    struct _TrieNode *first;    //first element of index
    struct _TrieNode *next;        //next element of index
    struct _TrieNode **sons;    //hash array
    int size;            //hash array size
    int used;            //son number
    wchar_t *value;            //value
    wchar_t *pinyin;        //is end of word or middle   1:true   0:false  
}TrieNode,*pTrieNode;

inline int treehash(TrieNode *p,wchar_t* value);
inline int hashfactor(int x);
void initTrieNode(pTrieNode pInitnode,wchar_t* v);
void indexadd(pTrieNode root, wchar_t *word, wchar_t *pinyin);
void index2tree(TrieNode *cur);
wchar_t * treefind(TrieNode *root, wchar_t *word);
void indexaddotherlayer(pTrieNode root, wchar_t *word, wchar_t *pinyin, TrieNode **ppFirstNode);
void indexaddfirstlayer(pTrieNode root, wchar_t *word, wchar_t *pinyin, TrieNode **ppFirstNode );
#endif
